<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var sum = 0;
        var tool = prompt("请输入您要的操作:\n1.存钱\n2.取钱\n3.显示余额\n4.退出")
        while (tool != 4) {
            if (tool == 1) {
                var inNum = prompt("您要存多少钱?")
                if (inNum != 0) {
                    sum += inNum;
                    alert("帮您存好了")
                } else {
                    alert('您不能存入0元!')
                }
                tool = prompt("请输入您要的操作:\n1.存钱\n2.取钱\n3.显示余额\n4.退出")
            } else if (tool == 2) {
                var outNum = prompt("您要取多少钱?")
                if (outNum != 0) {
                    sum -= outNum
                    alert("帮您取好了")
                } else {
                    alert('您不能取出0元!')
                }
                tool = prompt("请输入您要的操作:\n1.存钱\n2.取钱\n3.显示余额\n4.退出")
            } else if (tool == 3) {
                alert('您的余额为:' + sum);
                tool = prompt("请输入您要的操作:\n1.存钱\n2.取钱\n3.显示余额\n4.退出")
            } else if (tool == 4) {
                alert("欢迎下次光临")
                break;
            } else {
                alert('请输入正确的操作');
                tool = prompt("请输入您要的操作:\n1.存钱\n2.取钱\n3.显示余额\n4.退出")
            }
        }
    </script>
</body>

</html>